/**
 * 
 */
package edu.buu.refectory.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import edu.buu.refectory.dao.RefectoryMapper;
import edu.buu.refectory.domain.Refectory;
import edu.buu.refectory.utils.MD5Util;

/**
 * @author Bruce<br>
 * @version 1.0<br>
 * @CreateDate 30 Apr 2016 <br>
 */
@Service
public class RefectoryService {

	@Autowired
	private RefectoryMapper dao;
	
	/**
	 * @param username
	 * @return
	 */
	public List<Refectory> getByUsername(String username) {
		return dao.getByUsername(username);
	}

	/**
	 * @param map
	 * @return
	 */
	public List<Refectory> getList(Map<String, Object> map) {
		return dao.getList(map);
	}

	/**
	 * @param refectory
	 * @return
	 */
	public Refectory create(Refectory refectory) {
		refectory.setrKey(MD5Util.encrypt(refectory.getrKey(), refectory.getrUsername()));
		dao.insert(refectory);
		return dao.selectByPrimaryKey(refectory.getrId());
	}

	
}
